<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>SGMI</title>
    </h:head>
    <h:body>
            <h:form>
                <center>
                    <p:panel header="Cadastrar Departamentos" >
                        <p:panelGrid columns="2">
                            Descrição: <h:inputText id="descricaoDepart" value="#{departamentosBean.departamento.descricao}" />
                            <h:inputHidden /> 
                            <p:commandButton value="Cadastrar" action="#{departamentosBean.adicionarDepartamento}"/>
                        </p:panelGrid>
                        <br/><br/>
                        <p:dataTable value="#{departamentosBean.listarDepartamentos()}" var="dataDepart" paginator="true" rows="5">
                            <p:column>
                                <f:facet name="header">
                                    Centro de custo                        
                                 </f:facet>
                                 <h:outputText value="#{dataDepart.codDepartamento}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                     Descrição                        
                                </f:facet>
                                <h:outputText value="#{dataDepart.descricao}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    Ações                        
                                </f:facet>
                                <h:commandLink value="Excluir" action="#{departamentosBean.removerDepartamento(dataDepart)}" />
                                | <h:commandLink value="Alterar" action="#{departamentosBean.carregarDepartamento(dataDepart)}"/>
                            </p:column>
                        </p:dataTable>
                        
                    </p:panel>
                </center>
            </h:form>
       
    </h:body>
</html>

